﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="mylist.aspx.cs" Inherits="jnlamp.Web.areainfo.mylist" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
     <script type="text/javascript">
         $(function () {
             InitTree();
         });
         function InitTree() {
             $('#p').panel({
                 //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                 height:'100%',
                 title: '地区信息'

             });
             $('#tt').tree({
                 url: 'GetArea.ashx', //请求数据的页面               
                 //width: '400', //宽度
                 //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                 lines: true,
                 method: 'post',
                 queryParams: { "action": "query" },
                 formatter: function (node) {
                     return node.bm + " " + node.text;
                 }
             });
             $('#myp').panel({
                 //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                 height: '100%',
                 title: '本地地区信息'

             });
             $('#mytt').tree({
                 url: 'GetArea.ashx', //请求数据的页面               
                 //width: '400', //宽度
                 //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                 lines: true,
                 method: 'post',
                 queryParams: { "action": "querymy" },
                 formatter: function (node) {
                     return node.bm + " " + node.text;
                 }
             });
         }

         function newNode() {
             $('#fm').form('clear');
             var node = $('#tt').tree('getSelected');
             if (node != null) {
                 $('#parentid').val(node.id);
                 $('#fm').form('submit', {
                     url: "GetArea.ashx?action=addmynode&aid=" + node.id,
                     success: function (result) {
                         if (result.indexOf("T") == 0) {
                             $('#dlg').dialog('close');
                             $.messager.alert("提示", "恭喜您，信息添加成功", "info");
                             $('#mytt').tree('reload');
                         }
                         else if ((result.indexOf("F") == 0)) {
                             $.messager.alert("提示", "添加失败，请重新操作！", "info");
                             return;
                         }
                         else if ((result.indexOf("L") == 0)) {
                             $.messager.alert("提示", "长时间没有操作，请重新登录！", "info");
                             top.location = '/index.aspx';
                             return;
                         }
                     }
                 });
             }
             else {
                 $.messager.alert("提示", "请选择要设置的数据！", "info");

             }

         }
         function removeUser() {
             var row = $('#mytt').tree('getSelected');
             if (row == null) {
                 $.messager.alert("提示", "请选择要删除的数据！", "info");
             }
             if (row) {
                 $.messager.confirm('提示', '你确定要删除这条信息吗？', function (r) {
                     if (r) {
                         $('#fm').form('submit', {
                             url: 'GetArea.ashx?maid=' + row.id + "&action=deletemy",
                             onSubmit: function () {
                             },
                             success: function (result) {
                                 if (result.indexOf("T") == 0) {
                                     $.messager.alert("提示", "恭喜您，信息删除成功！", "info");
                                     $('#mytt').tree('reload');
                                 }
                                 else {
                                     $.messager.alert("提示", "删除失败，请重新操作！", "info");
                                     return;
                                 }
                             }
                         });
                     }
                 })

             }
         }

    </script>
    <style type="text/css">
        html, body {
            height: 100%;
        }

        .fitem label {
            width: 100px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     <div class="easyui-layout" style="width: 100%; height: 100%;" id="mycon">
        <div region="west" split="true" style="width: 280px; overflow: auto" id="west">
            <div id="p" class="easyui-panel" data-options="iconCls:'icon-save',tools:'#tab_toolbar'" style="overflow: auto;">
                <ul id="tt"></ul>
            </div>

        </div>
        <div region="center" style="background: #eee; overflow: auto" >
            <div id="myp" class="easyui-panel" data-options="iconCls:'icon-save',tools:'#tab_toolbar2'" style="overflow: auto;">
                <ul id="mytt"></ul>
            </div>

        </div>



    </div>
    <div id="tab_toolbar">
        <a href="#" onclick="newNode();" id="a_add" class="icon-add" style="margin-right: 10px"></a>       
       
    </div>
    <div id="tab_toolbar2">
        <a href="#" onclick="removeUser();return false;" id="a2" class="icon-cancel" style="margin-right: 10px"></a>
    </div>
    <div id="dlg" class="easyui-dialog" style="width: 350px; height: auto; padding: 10px 20px"
        data-options="closed:true,shadow:false">
        <form id="fm" method="post">            
        </form>
    </div>
    
</asp:Content>
